/*
 * @Author: Salaing
 * @Date: 2024-07-16 19:25:19
 * @LastEditors: Salaing
 * @LastEditTime: 2024-07-29 00:34:26
 * @Description: file content
 */
import React from 'react';
import { Link } from 'react-router-dom';
import { Button, ConfigProvider } from 'antd';
import { selectLayout } from 'utils/selectLayout';
import BaseLayout from './BaseLayout';
import LoginLayout from './LoginLayout';
import Loading from 'components/Loading';
import { useSelector } from 'umi';
import zhCN from 'antd/es/locale/zh_CN';

const Layout = ({ children, history, location }) => {
  const layoutMap = { BaseLayout, LoginLayout }; // 定义布局映射，键为布局名称，值为对应的组件。
  const Container = layoutMap[selectLayout(location.pathname)]; // 根据当前路径选择对应的布局组件。
  const loading = useSelector((state) => state.loading);

  return (
    <ConfigProvider locale={zhCN}>
      <Container>
        <Loading isShow={loading.effects['user/login']} />
        {children}
      </Container>
    </ConfigProvider>
  ); // 渲染选中的布局组件，并将子组件传递给它。
};

export default Layout;
